import axios from 'axios'
import {getCookie} from './cookie'
export function getInstance() {
  const instance = axios.create({
    timeout: 5000,
  });
  instance.interceptors.request.use(
    config => {
      const token = getCookie('csrfToken');
      if(token) {
        config.headers['x-csrf-token'] = token;
      }
      return config;
    },
    err => {
      return Promise.reject(err)
    }
  )
  return instance;
}